#include "ThreadPool.h"

#include <unistd.h>
#include <iostream>
#include <mutex>

using namespace std;
using namespace util;

int a, b;
int d = 0;

class MyTask : public Task
{
public:
    MyTask() = default;
    ~MyTask() = default;
    virtual void* run() override
    {
        d = a + b;
        return (void*)&d;
    }
    int a = 3, b = 4;
    int d = 0;
};


int main()
{
    ThreadPool pool(1024, 1, 1);
    pool.start();

    for (int i = 0; i < 10010; i ++ )
    {
        MyTask mytask;
        mytask.a = i;
        mytask.b = i + 1;
        auto task = std::make_shared<MyTask>(mytask);
        auto res = pool.submit(task);
        auto ans = res.get();
        cout << "main get ans:" << *((int*)ans) << endl;
    }
	return 0;
} 